﻿#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*#include <bios.h>*/
#define ShowMsg(strerror)\
{\
printf("%s\n",strerror);\
}
struct PT_tag
{

};

#ifndef _BD_
#define _BD_
int biosdisk(int cmd, int drive, int head, int track, int sector,int nsects, void *buffer)
{
    return 0;
}
#endif

/*扇区 柱面 磁头*/
int GetDiskSizeParaMeter(int *piHeadMax,int *piCyMAx,int *piSecMax)
{
    char szbuffer[512]={0};
    int i,j,k;

    for(i=0;i<=0xffff;i++)
    {
        if(biosdisk(2,0x80,i,0,1,1,szbuffer)!=0)
        {
            *piHeadMax=i;
            printf("Max Head:%d\n",i);
            break;
        }
    }

    for(i=0;i<=0xffff;i++)
    {
        if(biosdisk(2,0x80,0,i,1,1,szbuffer)!=0)
        {
            *piCyMAx=i;
            printf("Max Cy:%d\n",i);
            break;
        }
    }

    for(i=1;i<=0xffff;i++)
    {
        if(biosdisk(2,0x80,0,0,i,1,szbuffer)!=0)
        {
            *piSecMax=i;
            printf("Max Sector:%d\n",i);
            break;
        }
    }
    return 1;
}

int main()
{
    float fSize;
    char szMBR[512]={0};
    int iMaxSec,iMaxCy,iMaxHead;
    GetDiskSizeParaMeter(&iMaxHead,&iMaxCy,&iMaxSec);
    printf("Disk Size %u\n",(unsigned long)iMaxHead*(iMaxSec-1)*iMaxCy*512/1024/1024);
    getchar();
    return 0;
}
